from google.appengine.ext import webapp
import urllib

import settings
import model.alert
from helper import template


class Handler(webapp.RequestHandler):
    def get(self, *args):
        args = list(args[1::2])
        if args[1]:
            args += urllib.unquote(args[1]).split(':')
            args.pop(1)
        if args[0] == 'alerts':
            if args[1] == 'delete':
                model.alert.delete(args[2])
            settings.HTML_PARAMS['content'] = template.get(
                'templates/alerts.html',
                model.alert.getHtmlParams(args)
            )
        
        out = template.get('templates/index.html', settings.HTML_PARAMS) 
        self.response.out.write(out)
